import Cookies from './cookie';
import CryptoJS from 'crypto-js';

export function encrypt (word: string) { // 加密
  const keyStr = Cookies.get('loginEncryptionKey');
  return CryptoJS.AES.encrypt(JSON.stringify(word), keyStr).toString();
}

export function decrypt (word: string) { // 解密
  const keyStr = Cookies.get('loginEncryptionKey');
  const bytes = CryptoJS.AES.decrypt(word, keyStr).toString(CryptoJS.enc.Utf8);
  return JSON.parse(bytes.toString());
}
